<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Queue\Capsule\Manager;
use App\OperationLog;
use Illuminate\Support\Facades\Auth;

class OperationLogController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }


	public function index() {
		$operationLogs = OperationLog::getOperationLogList();
		$data['operationLogs'] = $operationLogs;

		return view('operationLog.list')->with($data);
	}



	public function delete(Request $request)
	{
		$uid = $request->id;
        if(!$uid){
            return '-1';
        }

        //  del
		$affectId= OperationLog::where('id',$uid)->update([
			'is_del'=>-1
		]);
//        $affectId = OperationLog::where('id',$uid)->delete();
        if(!$affectId){
            return -1;
        }

		$adminUser = Auth::user();
		if($adminUser){
			$userId = $adminUser->id;
			$logs = $adminUser->name.'在'.date('Y-m-d H:i:s').'删除了日志';
			adminOperationLog($request,$userId,$logs);
		}
        return 1;
	}
}





